#ifndef _SDMMC_SDCARD_H
#define _SDMMC_SDCARD_H

#include "sys.h"
#include "stm32f4xx_hal.h"
//////////////////////////////////////////////////////////////////////////////////	 
//本程序只供学习使用，未经作者许可，不得用于其它任何用途
//ALIENTEK STM32F07开发板
//SD卡驱动代码	   
//正点原子@ALIENTEK
//技术论坛:www.openedv.com
//创建日期:2017/4/18
//版本：V1.0
//版权所有，盗版必究。
//Copyright(C) 广州市星翼电子科技有限公司 2014-2024
//All rights reserved									  
//////////////////////////////////////////////////////////////////////////////////

#define SD_TIMEOUT 			((uint32_t)100000000)  	//超时时间
#define SD_TRANSFER_OK     	((uint8_t)0x00)
#define SD_TRANSFER_BUSY   	((uint8_t)0x01)

#define SD_DMA_MODE    		0						//1：DMA模式，0：查询模式   

extern SD_HandleTypeDef        SDCARD_Handler;     	//SD卡句柄
extern HAL_SD_CardInfoTypeDef  SDCardInfo;         	//SD卡信息结构体

unsigned char SD_Init(void);
unsigned char SD_GetCardInfo(HAL_SD_CardInfoTypeDef *cardinfo);
unsigned char SD_GetCardState(void);
unsigned char SD_ReadDisk(unsigned char* buf,unsigned int sector,unsigned int cnt);
unsigned char SD_WriteDisk(unsigned char *buf,unsigned int sector,unsigned int cnt);
unsigned char SD_ReadBlocks_DMA(uint32_t *buf,uint64_t sector,uint32_t blocksize,uint32_t cnt);
unsigned char SD_WriteBlocks_DMA(uint32_t *buf,uint64_t sector,uint32_t blocksize,uint32_t cnt);
int sd_read(unsigned int off_set, void *buf, int len);
int sd_write(unsigned int off_set, const void *buf, int len);
#endif
